const express = require('express');
const activity = require("../module/activity/activity");
const line = require("../module/line/line");
const router = express.Router();
const fs = require('fs').promises;

router.post('/addActivity', async(req, res) => {
  const data = await activity.addActivity(req)
  res.json(data)
})

// 获取活动列表
router.get('/list', async(req, res) => {
  const data = await activity.getActivityList(req.query)
  res.json(data)
})

// 获取当前用户创建或参与的活动
router.get('/getMyActivity', async(req, res) => {
  const loginStatus = await global.tokenFun.checkToken(req)
  if (loginStatus.loginStatus) {
    const data = await  activity.getMyActivity({
      ...loginStatus.loginRows,
      ...req.query
    })
    res.json(data)
  }else {
    res.json(loginStatus.msg)
  }
})

//


module.exports = router;
